package com.brillilab.service.module.message.template.impl.instrument;

import com.brillilab.common.rocketmq.OnsMessageEnum;
import com.brillilab.common.rocketmq.OnsMessageVo;
import com.brillilab.domain.po.instrument.Instrument;
import com.brillilab.domain.po.instrument.InstrumentAppointment;
import com.brillilab.domain.po.message.Message;
import com.brillilab.domain.vo.instrument.AppointmentVo;
import com.brillilab.domain.vo.user.UserInfoVo;
import com.brillilab.service.logic.instrument.converter.AppointmentConverter;
import com.brillilab.service.module.message.enums.MessageTargetEnum;
import com.brillilab.service.module.message.template.AbstractMessageTemplate;
import com.brillilab.service.module.message.template.enums.MessageTypeEnum;
import lombok.Data;

@Data
public class AppointmentAlertTemplate extends AbstractMessageTemplate {
    private String labName;
    private Integer instrumentNo;
    private String instrumentName;
    private String startTime;
    private String endTime;

    public AppointmentAlertTemplate(Long receiverId,Long labMemberId,Long labId,String labName,Instrument instrument,InstrumentAppointment appointment) {
        super(labId,receiverId);
        AppointmentVo appointmentVo=AppointmentConverter.appointmentToAppointmentVo(appointment);
        this.labName=labName;
        this.labMemberId=labMemberId;
        this.instrumentNo=instrument.getNo();
        this.instrumentName=instrument.getName();
        this.startTime=appointmentVo.getStartDate();
        this.endTime=appointmentVo.getEndDate();
        this.referId = appointmentVo.getId();
        super.setType(MessageTypeEnum.InstrumentAppointmentAlert.getValue());
        super.setTitle("仪器预约提醒");

        StringBuilder context=new StringBuilder();
        context.append("<span>您预约的【").append(this.startTime)
                .append(" - ").append(this.endTime)
                .append("】使用【").append(this.labName)
                .append("】的【").append(this.instrumentNo)
                .append("号】仪器【").append(this.instrumentName)
                .append("】将于10分钟后开始，请做好准备。</span>");
        super.setContent(context.toString());
        super.setAppContent(context.toString());
    }


}
